package com.example.sup.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @ClassName ApplicationContextUtil
 * @Description {TODO}
 * @Author 李哲
 * @Date 11:43 2024/8/1
 * @Version 1.0
 */
@Component
public class ApplicationContextUtil implements ApplicationContextAware {
    private static ApplicationContext context;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context =applicationContext;
    }

    public static <T> T getBean(String beanName,Class<T> clazz){
        return context.getBean(beanName,clazz);
    }
}